package jsyf.oa.web.socket;

import io.swagger.annotations.Api;
import jsyf.oa.entity.system.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;

import javax.servlet.http.HttpServletRequest;
import java.util.UUID;

/**
 * Created by Administrator on 2018/7/23 0023.
 */
@Api(value = "socket接口", description = "socket接口")
@Controller
@RequestMapping("/socket")
public class SocketController {

 /*   @Autowired
    private MyWebSocketHandler msgScoketHandle;

    @RequestMapping("login")
    public String login(UserEntity user, HttpServletRequest request) {
        user.setId(UUID.randomUUID().toString().replace("-", ""));
        request.getSession().setAttribute("user", user);
        return "/index";
    }

    @ResponseBody
    @RequestMapping("sendMsg")
    public String sendMag(String content, String toUserName) {
        UserEntity user = new UserEntity();
        user.setName(toUserName);
        TextMessage textMessage = new TextMessage(content);
        msgScoketHandle.sendMessageToUser(user, textMessage);
        return "200";
    }*/
}
